from sqlalchemy import Column
from cycdm.t1.sqlalchemy_util import *;
from datetime import datetime;
from cycdm.t1.md5_util import *;

from cycdm.t1.sqlalchemy_util import Base

'''
User 对象
'''

class User(Base):
    # 指定表名
    __tablename__ = "account_user";

    # 指定编码
    __table_args__ = {
        "mysql_charset":"utf8"
    }

    # 指定主键列
    id = Column(Integer, primary_key=True, autoincrement=True, nullable=False);
    # 指定非主键列
    user_name = Column(String(255));
    password = Column(String(255));
    email = Column(String(255));
    create_date = Column(DateTime);

if __name__ == '__main__':
    # 初始化 user 表格
    init_table();
    user = User(user_name="sg", password=get_md5("111111"), email="hj3@163.com",
         create_date=datetime.now().strftime("%Y-%m-%d %H:%M:%S"));
    insert_(user, "user_name");
    update_(user, "id");
    delete_(user, "id");
    result = get_(user, "id");
    result = get_all_(user);
    print(result);